package com.chwn.curiousdiary.download;

import android.text.TextUtils;

import com.chwn.harulib.util.TimeUtils;

import java.io.Serializable;

/**
 * Created by Myshikin on 2017/4/27.
 */

public class DownloadBean implements Serializable {

    private String storyId;

    private String storyName;

    private String storyImage;

    private String storyDesc;

    private String saveDirPath;

    private String stroyShareURL;

    private String url;


    /**
     * V1.1.5添加
     */
    private String storyListenCount;

    private String storyCreateTime;

    /**
     * 故事类型ID
     */
    private String typeId;

    public String getStoryListenCount() {
        return storyListenCount;
    }

    public void setStoryListenCount(String storyListenCount) {
        this.storyListenCount = storyListenCount;
    }

    public String getStoryListenCountString() {
        String count = storyListenCount;
        try {
            if (Integer.parseInt(storyListenCount) > 10000) {
                count = Integer.parseInt(storyListenCount) / 10000 + "." + (Integer.parseInt(storyListenCount) % 10000) / 1000 + "万";
            }else {
                count = storyListenCount;
            }
        } catch (Exception e) {
            e.printStackTrace();
        }

        return count;
    }

    public String getStoryCreateTime() {
        return this.storyCreateTime;
    }

    public String getStoryCreateTimeString() {
        if (TextUtils.isEmpty(storyCreateTime) || "未知".equals(storyCreateTime)) {
            return "未知";
        }
        return TimeUtils.getUpdateTime(storyCreateTime);
    }

    public void setStoryCreateTime(String storyCreateTime) {
        this.storyCreateTime = storyCreateTime;
    }

    public String getTypeId() {
        return typeId;
    }

    public void setTypeId(String typeId) {
        this.typeId = typeId;
    }

    private int downloadStatus;

    private long totalSize;

    private long completedSize;

    private boolean isOpenDelete;

    public DownloadBean() {
    }

    public DownloadBean(String storyId, String storyName,
                        String storyImage, String storyDesc,
                        String saveDirPath, String stroyShareURL,
                        String url, int downloadStatus,
                        long totalSize, long completedSize,
                        String storyCreateTime, String storyListenCount, String typeId) {
        this.storyId = storyId;
        this.storyName = storyName;
        this.storyImage = storyImage;
        this.storyDesc = storyDesc;
        this.saveDirPath = saveDirPath;
        this.stroyShareURL = stroyShareURL;
        this.url = url;
        this.downloadStatus = downloadStatus;
        this.totalSize = totalSize;
        this.completedSize = completedSize;

        this.storyCreateTime = TextUtils.isEmpty(storyCreateTime) ? "未知" : storyCreateTime;
        this.storyListenCount = TextUtils.isEmpty(storyListenCount) ? "未知" : storyListenCount;
        this.typeId = TextUtils.isEmpty(typeId) ? "-1" : typeId;
    }

    @Override
    public String toString() {
        return "DownloadBean{" +
                "storyId='" + storyId + '\'' +
                ", storyName='" + storyName + '\'' +
                ", storyImage='" + storyImage + '\'' +
                ", storyDesc='" + storyDesc + '\'' +
                ", saveDirPath='" + saveDirPath + '\'' +
                ", stroyShareURL='" + stroyShareURL + '\'' +
                ", url='" + url + '\'' +
                ", downloadStatus=" + downloadStatus +
                ", totalSize=" + totalSize +
                ", completedSize=" + completedSize +
                '}';
    }

    public String getStroyShareURL() {
        return stroyShareURL;
    }

    public void setStroyShareURL(String stroyShareURL) {
        this.stroyShareURL = stroyShareURL;
    }

    public String getStoryImage() {
        return storyImage;
    }

    public void setStoryImage(String storyImage) {
        this.storyImage = storyImage;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public String getStoryId() {
        return storyId;
    }

    public void setStoryId(String storyId) {
        this.storyId = storyId;
    }

    public String getStoryName() {
        return storyName;
    }

    public void setStoryName(String storyName) {
        this.storyName = storyName;
    }

    public String getStoryDesc() {
        return storyDesc;
    }

    public void setStoryDesc(String storyDesc) {
        this.storyDesc = storyDesc;
    }

    public String getSaveDirPath() {
        return saveDirPath;
    }

    public void setSaveDirPath(String saveDirPath) {
        this.saveDirPath = saveDirPath;
    }

    public int getDownloadStatus() {
        return downloadStatus;
    }

    public void setDownloadStatus(int downloadStatus) {
        this.downloadStatus = downloadStatus;
    }

    public long getTotalSize() {
        return totalSize;
    }

    public void setTotalSize(long totalSize) {
        this.totalSize = totalSize;
    }

    public long getCompletedSize() {
        return completedSize;
    }

    public void setCompletedSize(long completedSize) {
        this.completedSize = completedSize;
    }
}
